package me.aurora.service.impl;

import me.aurora.domain.Role;
import me.aurora.domain.User;
import me.aurora.repository.RoleRepo;
import me.aurora.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

/**
 * @author 郑杰
 * @date 2018/08/23 17:27:03
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleRepo roleRepo;

    @Override
    public List<Map<String, Object>> buildRoleTree(List<Role> roles) {
        List<Map<String,Object>> maps = new LinkedList<>();
        for (Role role:roles) {
            if (role!=null){
                Map<String,Object> map = new HashMap<>(16);
                map.put("id",role.getId());
                map.put("name",role.getName());
                maps.add(map);
            }
        }
        return maps;
    }

    @Override
    public List<Role> getAllRole() {
        return roleRepo.findAll();
    }
}
